/**
 * @description c端用户模块api
 */

import { http } from '../http'

const { get, put, post, delete: del, download } = http

// 前台---项目案例
export const itemCaseApi = {
  list: get('/spa/course/v1/project/user/'), //列表页面
  detail: (id: string) => get(`/spa/course/v1/project/user/${id}`), //查询项目案例详情
  getFileContent: (path: string) => get(`/spa/course/v1/proj/getCodeDetails?path=${path}`), //获取文件内容
  getOnlineExperience: get('/spa/course/v1/project/user/getOnlineExperience') //在线体验
}

// 前台---模型库
export const modelLibraryApi = {
  //公共模型
  commonModelList: get('/spa/data/v1/commom-model/user/'), //分页查询公共模型
  labelInfo: get(`/spa/data/v1/commom-model-label/user/info`), //获取所有公共模块所用标签的信息
  commonModelDetail: (id: string) => get(`/spa/data/v1/commom-model/user/${id}`), //根据ID查询公共模型
  getFileContent: (path: string) => get(`/spa/data/v1/model/getCodeDetails?path=${path}`), //获取文件内容

  //我的模型库
  myModelList: get('/spa/data/v1/model-base'), //分页查询我的模型库
  renameMyModel: put('/spa/data/v1/model-base/rename'), //重命名模型库
  delMyModel: (id: string) => del(`/spa/data/v1/model-base/${id}`), //删除我的模型库
  addMyModel: post(`/spa/data/v1/model-base`), //创建我的模型库
  myModelDownload: get(`/spa/data/v1/model-base/download`), //下载模型库
  getShareList: get('/spa/data/v1/model-base/share-info/:id'),
  share: post('/spa/data/v1/share-info/2'),
  removeShareUser: del('/spa/data/v1/share-info/:id'),
  addModalVersion: post('/spa/data/v1/model-info'),
  delModalVersion: del('/spa/data/v1/model-info'),

  //我的模型详情
  detailsList: get('/spa/data/v1/model-info'), //分页查询我的模型详情
  detailsDownload: download(`/spa/data/v1/model-info/download`), //下载
  detailsDel: del(`/spa/data/v1/model-info`), //单个删除
  batchDeletion: del(`/spa/data/v1/model-info/batch`), //批量删除
  detailsEdit: put('/spa/data/v1/model-info'), //编辑模型文件
  uploadModel: post('/spa/data/v1/model-info'), //上传模型文件
  deleteNotUploaded: post(`/spa/data/v1/model-info/files`), //删除已上传未记录的模型文件
  existingVersionNumber: get('/spa/data/v1/model-info/versions'), //列表查询已有版本号
  preUploadASingleFile: post('/spa/data/v1/model-info/presigned'), //预上传
  getModelInfo: get('/spa/data/v1/model-base-info/simpleInfo'), //获取模型库基本信息
  //获取可视化模型文件访问地址
  getVisualizeModelUrl: get('/spa/data/v1/model-info/visualize')
}

// 前台---收藏
export const collectionApi = {
  projectFavorite: get('/spa/authorization/v1/projectFavorite'), //我的收藏项目
  courseFavorite: get('/spa/authorization/v1/courseFavorite'), //我的收藏课程
  bucketFavorite: get('/spa/authorization/v1/bucketFavorite'), //我的收藏数据
  commonModelFavorite: get('/spa/authorization/v1/commonModelFavorite') //我的收藏公开模型库
}

// 用户个人中心模块
export const personalApi = {
  userToken: get('/spa/authorization/v1/user/token'), // 用户个人详情
  editName: put('/spa/authorization/v1/user/username'), //修改名称
  editTel: put('/spa/authorization/v1/user/tel'),
  editPass: put('/spa/authorization/v1/user/password'),
  editEmail: put('/spa/authorization/v1/user/bind-email'),
  checkTel: post('/spa/authorization/v1/user/check-unbind'),
  checkEmail: post('/spa/authorization/v1/user/check-mail'),
  sendMail: post('/spa/authorization/v1/user/send-mail'),
  verifyToken: get('/spa/authorization/v1/verify-token')
}

// 课程广场
export const classSquareApi = {
  list: get('/spa/course/v1/course/user'),
  getSquire: (id: string) => get(`/spa/course/v1/course/user/${id}`),
  downloadAll: get('/spa/course/v1/course/fileDownload') //下载全部的可成文件
}

// 客户端-公开数据集
export const customerPublicDataSetApi = {
  list: get('/spa/data/v1/bucket/common/user'), // 查询公开数据集
  download: get(`/spa/data/v1/bucket/common/download`), //下载
  publicInfo: get('/spa/data/v1/bucket-info/common') //详情
}

// 我的数据集
export const customerMyDateSetApi = {
  list: get('/spa/data/v1/bucket/user'), // 分页查询
  download: get('/spa/data/v1/bucket/user/download'), // 下载个人数据集
  delete: del('/spa/data/v1/bucket/user'), // 删除个人数据集
  rename: put('/spa/data/v1/bucket/user'), //重命名个人数据库
  add: post('/spa/data/v1/bucket/user'), //添加
  idFind: get('/spa/data/v1/bucket/user/simpleInfo'), //通过id查询
  downloadAll: post('/spa/data/v1/private/bucket-info/download/all'), // 全部下载
  delDir: del('/spa/data/v1/private/bucket-info/dir'), //删除文件夹
  deleteInBatches: del('/spa/data/v1/private/bucket-info'), //批量删除数据集详情表格
  createFile: post('/spa/data/v1/private/bucket-info/dir'), //创建文件夹
  editFile: put('/spa/data/v1/private/bucket-info/dir'), //编辑文件夹
  getReadyUpload: post('/spa/data/v1/bucket-info/private/presigned'), // 预上传接口
  delSignal: del('/spa/data/v1/private/bucket-info/:id'), // 单个删除
  detail: get('/spa/data/v1/private/bucket-info'), // 详情
  selectOption: get('/spa/data/v1/private/bucket-info/file-type'), // 详情的下拉列表数据
  getTierInfo: (id: string | number) => get(`/spa/data/v1/private/bucket-info/dir?id=${id}`), // 获取文件夹父级信息
  previewArea: (id: string) => get(`/spa/data/v1/private/bucket-info/preview?id=${id}`), // 数据集预览
  downloadDir: get('/spa/data/v1/private/bucket-info/dir/download'), //下载文件夹
  downloadInfo: get('/spa/data/v1/private/bucket-info/download'), //下载文件
  // 根据文件相对路径获取文件minio地址
  getMinioUrl: get('/spa/data/v1/sys-download-record/download'),
  downloadBatch: post('/spa/data/v1/private/bucket-info/download/batch'), //批量下载
  getShareList: get('/spa/data/v1/bucket/user/share-info/:id'),
  share: post('/spa/data/v1/share-info/1'),
  removeShareUser: del('/spa/data/v1/share-info/:id'),
  // 数据看板
  getOverview: get(`/spa/data/v1/bucket/user/overview`), // 数据概览

  getBoard: get('/spa/data/v1/bucket/user/board'), // 数据看板基础数据
  // 记录全部下载日志
  recordAllDownload: post('/spa/data/v1/bucket-info/download/all')
}

// 个人数据集上传
export const privateFileApi = {
  preUploadASingleFile: post('/spa/data/v1/private/bucket-info/presigned'), //预上传单个文件
  uploadASingleFile: post('/spa/data/v1/private/bucket-info/one') //上传单个文件
}
/* 用户端打榜竞技 */
export const hitContestApi = {
  list: get('/spa/task/v1/pk-task/user'),
  recentList: get('/spa/task/v1/pk-task/user/recent'),
  rankList: get('/spa/task/v1/pk-task/user/rank'),
  myRecord: get('/spa/task/v1/pk-task/user/myRecord'),
  detail: get('/spa/task/v1/pk-task'),
  participation: post('/spa/task/v1/pk-task-user-record'),
  myList: get('/spa/task/v1/pk-task/user/recent/list'),
  getTaskDir: get('/spa/task/v1/pk-task-user-record/upload-dir')
}

/* 算法服务 */
export const algoServiceApi = {
  typeList: get('/spa/authorization/v1/dictionary/center'),
  list: get('/spa/algorithm/v1/algorithm-services/center'),
  hotWord: get('/cloud/thirdparty/v1/algorithm-hot-key-words'),
  docs: get('/spa/algorithm/v1/algorithm-services/center/operateDocument'),
  detail: (id: string) => get(`/spa/algorithm/v1/algorithm-service/center/${id}`)()
}
export const getFileUrl = (fileName: string) => get('/cloud/oss/minio/presigned-download')({ fileName })
